<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><{:C('web_site_name')}>----登录</title>
    <link href="<?php echo APP_TMPL_PATH ; ?>/static/css/admin_login.css" rel="stylesheet" type="text/css" />
</head>
<body style="background:url(<?php echo $bgpic ;?>)">
<div class="admin_login_wrap">
    <h1>管理后台登录</h1>
    <div class="adming_login_border">
        <div class="admin_input">
            <form action="<{:U('login/do_login')}>" method="post" onsubmit="return check()">
                <ul class="admin_items">
                    <li>
                        <label for="user">用户名：</label>
                        <input type="text" placeholder="用户名" name="username" value="" id="user" size="40" class="admin_input_style" />
                    </li>
                    <li>
                        <label for="pwd">密码：</label>
                        <input type="password" name="pwd" value="" placeholder="请输入密码" id="pwd" size="40" class="admin_input_style" onblur="checkUsernamePwd()"/>
                    </li>
                     <li>
                        <label for="code">验证码：</label>
                        <input type="text" placeholder="请输入验证码"  name="code" value="" id="code" size="40" class="admin_input_style" onblur="checkCode()" />
                    </li>
                     <li>
                        <label for="code">验证码：</label>
                        <img src="<{:U('login/verify')}>" class="verify_img" style="cursor:pointer">
                    </li>
                    <li>
                        <input type="submit" tabindex="3" value="提交" class="btn btn-primary" />
                    </li>
                     
                </ul>
            </form>
        </div>
    </div>
    <p class="admin_copyright"><a tabindex="5" href="http://www.speakphp.com/" target="_blank">返回首页</a> &copy; 2014 Powered by <a href="http://www.speakphp.com/" target="_blank">speakphp</a></p>
</div>
</body>
</html>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/lib.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/layer.min.js"></script>
<script>
$(function(){
    $(".verify_img").click(function(){
    	var timenow = new Date().getTime();
        $(this).attr("src","<?php echo U('login/verify') ;?>&t="+timenow)
    });
   
});
var check_username_pwd = false ;
var check_yzm = false ;
var loadding_0 ;
function check(){
    var username = $("#user").val();
    var pwd = $("#pwd").val();
    if(username == '' || pwd == '' ){
        layer.msg("用户名或者密码不可以为空");
        return false ;
    }
    s
    if(!check_username_pwd||!check_yzm ){
        return false;
    }
    return true ;

}
function checkUsernamePwd(){
    var username = $("#user").val();
    var pwd = $("#pwd").val();
    $.ajax({
    type: "POST",
    url: "<{:U('login/checkUsernamePwd')}>" ,
    data: {username:username , pwd:pwd},
    cache:false,
    dataType:"json",
    async:true,
    success: function(msg){
        if(msg.status!=1){
            layer.msg(msg.message);
            check_username_pwd = false ;
        }else{
           check_username_pwd  = true ;
        }
        layer.close(loadding_0);
        //return check_username_pwd ;
    },
    beforeSend:function(){
         loadding_0 = layer.load('数据正在加载中。。。。。。'); 
    },
    error:function(){
        layer.msg('服务器繁忙请稍后');
        return false ;
    }
    });
}

function checkCode(){
    var code = $("#code").val();
    if(code == '' ){
        layer.msg("请输入验证码");
        return false ;
    }
    $.ajax({
    type: "POST",
    url: "<{:U('login/checkCode')}>" ,
    data: {code:code},
    cache:false,
    dataType:"json",
    async:true,
    success: function(msg){
        if(msg.status!=1){
            layer.msg(msg.message);
            check_yzm = false ;
        }else{
           check_yzm  = true ;
        }
        layer.close(loadding_0);
        //return check_yzm ;
    },
    beforeSend:function(){
         loadding_0 = layer.load('数据正在加载中。。。。。。'); 
    },
    error:function(){
        layer.msg('服务器繁忙请稍后');
        return false ;
    }
    });
}


</script>
